<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>新增项目</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">

<!-- 百度地图推荐 -->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="js/zTree_v3/css/metroStyle/metroStyle.css" >

<script src="js/jquery-1.11.1.js"></script>
<script src="js/select2/select2.min.js"></script>
<script type="text/javascript" src="js/zTree_v3/js/jquery.ztree.core.min.js" ></script>
<script type="text/javascript" src="js/zTree_v3/js/jquery.ztree.excheck.min.js" ></script>
<script src="static/p_project/project-add.js" ></script>
<script type="text/javascript" src="js/form.js"></script>

<style type="text/css">
html {
	height: 100%
}

body {
	height: 100%;
	margin: 0px;
	padding: 0px
}
#deptTree{
	display: none;
	margin:0 69px 0 51px;
	background-color: #eee;
	height: 140px;
	overflow-y: auto;
	overflow-x: hidden;
}
.form-group {
    width: 600px;
}
</style>
<script type="text/javascript">
	$(function() {
		initS2();
		//初始化表单
		mySubmit("projectAddForm", initProjectAddData, projectAddCallback);
	});
	
	function initS2(){
		$("#projectType").select2();
	}
	
	//关闭当前layer
	function closeThis(){
		parent.layer.closeAll();
	}
	
	function initProjectAddData(){
		var projectName=$("#projectName").val();
		var projectType=$("#projectType").val();
		var projectCoordinate=$("#projectCoordinate").val();
		//公共产权人功能去掉
		//var onlyProperty = $("input[name='onlyProperty']:checked").val();
		var sarr=new Array();
		
		$.each(arrDept,function(i,v){
			sarr.push(v.id);
		});
		
		var result;
		if(projectName==""){
			result=null;
			alert("请输入项目名称!");
		}else if(projectCoordinate==""){
			result=null;
			alert("请输入坐标!");
		}else if(sarr.length<1){
			result=null;
			alert("请管理隶属!");
		}else{
			result= {
				projectName:projectName,
				deptCorr:sarr,
				projectType:projectType,
				projectCoordinate:projectCoordinate,
				onlyProperty:1
			}
		}
		return result;
	}
	
	function projectAddCallback(data,success){
		if(data.msg>0){
			parent.layer.alert("保存成功",{
				offset:'30%'
			},function(){
				parent.location.reload();
			});
		}else if(data.msg==-2){
			parent.layer.alert("项目名称已存在",{
				offset:'30%'
			});
		}
	}
	
</script>


</head>

<body>
	<div style="width: 360px;padding-top: 10px;margin-left: 100px;">
		<form id="projectAddForm" method="post" class="form-horizontal" action="projectInfo/addProjectInfo">
			<div class="form-group">
				<label for="projectType">项目类型</label> <select
					id="projectType" style="width:270px;">
					<option value="行政办公" selected="selected">行政办公</option>
					<option value="居住场所">居住场所</option>
					<option value="商业综合">商业综合</option>
					<option value="教育场所">教育场所</option>
					<option value="文博场所">文博场所</option>
					<option value="交通枢纽">交通枢纽</option>
					<option value="养老医疗">养老医疗</option>
					<option value="工业园区">工业园区</option>
				</select>
			</div>
			<div class="form-group">
				<label for="projectBtn">管理隶属</label>
				<input type="text" id="deptCorr" name="deptCorr" style="width: 270px;display: inline-block;cursor:pointer;" placeholder="点击选择..." readonly="readonly" class="form-control" >
				<ul id="deptTree" class="ztree"></ul>
			</div>
			<div class="form-group">
				<label for="projectName">项目名称</label> 
				<input type="text" style="width: 270px;display: inline-block;" class="form-control" id="projectName"
					placeholder="">
				<span style="color:#f00;display: none;" >*名称已存在</span>
			</div>
			<div class="form-group">
				<label for="projectAddress" >项目地址</label> 
				<input type="text" style="width: 270px;display: inline-block;"
					class="form-control" id="projectCoordinate" placeholder="点击选取坐标后复制到此...">
				<a href="http://api.map.baidu.com/lbsapi/getpoint/index.html"
					target="_blank">选取坐标</a>
			</div>
			<!-- 产权人唯一功能暂时去掉 -->
			<!-- <div class="form-group">
				<label>产权人唯一</label>
				<span class="mingcheng"style="width: 50px;"><input type="radio"value="0" name="onlyProperty" >是</span> 
				<span class="mingcheng" style="width: 50px;"><input type="radio" value="1" name="onlyProperty" checked="checked">否</span>
				<span id="msg" style="color:red">*</span>
			</div> -->
			<div class="form-group">
				<button type="submit" class="btn btn-danger" style="margin-left: 52px;" >保存</button>
				&nbsp;&nbsp;
				<button type="button" onclick="closeThis()" class="btn btn-default">取消</button>
			</div>
		</form>
	</div>
</body>
</html>
